<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"    
  	xmlns:cc="http://java.sun.com/jsf/composite"
  	xmlns:h="http://java.sun.com/jsf/html"
  	xmlns:p="http://primefaces.org/ui"
  	xmlns:f="http://java.sun.com/jsf/core"
  	xmlns:ui="http://java.sun.com/jsf/facelets">

	<!-- INTERFACE -->
	<cc:interface> 	 
    	<cc:attribute name="bill" />  
    	<cc:attribute name="duplicate" />
    	<cc:attribute name="hosCopy" />   	 
    	<cc:attribute name="showProfessional" />
	</cc:interface>

	<!-- IMPLEMENTATION -->
	<cc:implementation>
    	<h:outputStylesheet library="css" name="printing.css" />
    	<div>
        	<p:panel   id="gpBillPreview"  style="margin: auto; padding: 0px; font-size: 14px!important;" >
            	<div class="a4bill" >


                	<table class="headingPrinting" >

                    	<tr>
                        	<td colspan="4"><h:outputLabel class="mark" value="**Final Bill Summery**Duplicate**" rendered="#{cc.attrs.duplicate eq true}"/></td>
                    	</tr>
                    	<tr>
                        	<td colspan="4"><h:outputLabel class="mark" value="**Final Bill Summery**" rendered="#{cc.attrs.hosCopy eq true}"/></td>
                    	</tr>
                    	<tr>
                        	<td colspan="2">&nbsp;</td>
                    	</tr>
                	</table>
                	<table>
                    	<tr >
                        	<td >
                            	<h:outputLabel value="B.H.T NO" />
                        	</td>
                        	<td>
                            	<h:outputLabel value=":" />
                        	</td>
                        	<td >
                            	<h:outputLabel value="#{cc.attrs.bill.patientEncounter.bhtNo}" />
                        	</td>
                        	<td>
                            	<h:outputLabel value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" />
                        	</td>
                        	<td >
                            	<h:outputLabel value="BILL NO" />
                        	</td>
                        	<td>
                            	<h:outputLabel value=":" />
                        	</td>
                        	<td >
                            	<h:outputLabel value="#{cc.attrs.bill.insId}" />
                        	</td>
                    	</tr>
                    	<tr >
                        	<td >
                            	<h:outputLabel value="Patient Name" />
                        	</td>
                        	<td>
                            	<h:outputLabel value=":" />
                        	</td>
                        	<td >
                            	<h:outputLabel value="#{cc.attrs.bill.patientEncounter.patient.person.nameWithTitle}" />
                        	</td>                      	 
                    	</tr>

                	</table>

                	<table class="tbl"  >
                    	<h:panelGroup >
                        	<tr>
                            	<td style="text-align: left;font-size: 13px!important;font-weight: bold!important;">
                                	<h:outputLabel  value="Hospital Bill Total"/>
                            	</td>
                            	<td>&nbsp;</td>
                            	<td style="text-align: right;font-size: 13px!important;font-weight: bold!important;">
                                	<h:outputLabel value="#{cc.attrs.bill.hospitalFee-cc.attrs.bill.discount}" >
                                    	<f:convertNumber pattern="#,##0.00" />
                                	</h:outputLabel>  

                            	</td>
                        	</tr>
                        	<tr>
                            	<td colspan="3">
                                	<p:spacer height="10" />
                            	</td>
                        	</tr>
                    	</h:panelGroup>

                    	<h:panelGroup >
                        	<tr>
                            	<ui:repeat  class="tbl"  value="#{cc.attrs.bill.billItems}" var="bip">
                                	<h:panelGroup rendered="#{bip.inwardChargeType eq 'ProfessionalCharge'}">
                                    	<td style="text-align: left;font-size: 13px!important;font-weight: bold!important;">
                                        	<h:outputLabel  value="Professional Bill Total"/>
                                    	</td>
                                    	<td>&nbsp;</td>
                                    	<td style="text-align: right;font-size: 13px!important;font-weight: bold!important;">
                                        	<h:outputLabel value="#{bip.netValue}" >
                                            	<f:convertNumber pattern="#,##0.00" />
                                        	</h:outputLabel>  
                                    	</td>
                                	</h:panelGroup>
                            	</ui:repeat>
                        	</tr>
                        	<tr>
                            	<td colspan="3">
                                	<p:spacer height="10" />
                            	</td>
                        	</tr>
                    	</h:panelGroup>

                    	<h:panelGroup >
                        	<tr>
                            	<td>&nbsp;</td>
                            	<td>&nbsp;</td>
                            	<td style="text-align: right;"><h:outputLabel value="-------------------" /></td>
                        	</tr>
                        	<tr>
                            	<td style="text-align: left;font-size: 13px!important;font-weight: bold!important;">
                                	<h:outputLabel  value="Net Total"/>
                            	</td>
                            	<td>&nbsp;</td>
                            	<td style="text-align: right;font-size: 13px!important;font-weight: bold!important;">
                                	<ui:repeat  class="tbl2"  value="#{cc.attrs.bill.billItems}" var="bip">
                                    	<h:panelGroup rendered="#{bip.inwardChargeType eq 'ProfessionalCharge'}">
                                        	<h:outputLabel value="#{bip.netValue+cc.attrs.bill.hospitalFee-cc.attrs.bill.discount}" >
                                            	<f:convertNumber pattern="#,##0.00" />
                                        	</h:outputLabel>  
                                    	</h:panelGroup>
                                	</ui:repeat>
                            	</td>
                        	</tr>
                        	<tr>
                            	<td colspan="3">
                                	<p:spacer height="10" />
                            	</td>
                        	</tr>
                    	</h:panelGroup>

                    	<h:panelGroup >
                        	<!--                        	PAID AMOUNT-->
                        	<tr>
                            	<td style="text-align: left;font-size: 13px!important;font-weight: bold!important;">
                                	<h:outputLabel   value="Paid By Patient " rendered="#{cc.attrs.bill.paidAmount !=0}"/>
                            	</td>
                            	<td>
                                	<table>
                                    	<ui:repeat value="#{cc.attrs.bill.backwardReferenceBills}" var="b">
                                        	<h:panelGroup  rendered="#{(b.netTotal ne 0 )                                                                  	 
                                                                   	and                                                                   	 
                                                                   	((b.cancelled eq false
                                                                   	and b.billClass eq 'class com.divudi.entity.BilledBill')
                                                                   	or
                                                                   	(b.cancelled eq false
                                                                   	and b.refundedBill eq null
                                                                   	and b.billClass eq 'class com.divudi.entity.RefundBill'))}" >                                       	 
                                            	<tr>
                                                	<td>
                                                    	#{b.insId}
                                                	</td>                                              	 
                                                	<td>
                                                    	<h:outputLabel value="#{b.netTotal}">
                                                        	<f:convertNumber pattern="#,##0.00" />
                                                    	</h:outputLabel>
                                                	</td>
                                            	</tr>
                                        	</h:panelGroup>
                                    	</ui:repeat>
                                	</table>
                            	</td>
                            	<td style="text-align: right;font-size: 13px!important;font-weight: bold!important;">
                                	<h:outputLabel  value="#{cc.attrs.bill.paidAmount+cc.attrs.bill.patientEncounter.paidByCreditCompany}" rendered="#{cc.attrs.bill.paidAmount !=0}" >
                                    	<f:convertNumber pattern="#,##0.00" />
                                	</h:outputLabel>
                            	</td>
                        	</tr>
                        	<tr>
                            	<td colspan="3">
                                	<p:spacer height="10" />
                            	</td>
                        	</tr>
                    	</h:panelGroup>

                    	<h:panelGroup >
                        	<!--DUE AMOUNT-->
                        	<tr>
                            	<td>&nbsp;</td>
                            	<td>&nbsp;</td>
                            	<td style="text-align: right;"><h:outputLabel value="-------------------" /></td>
                        	</tr>
                        	<tr>
                            	<td style="text-align: left;font-size: 13px!important;font-weight: bold!important;">
                                	<h:outputLabel   value="Due Amount" />
                            	</td>
                            	<td>
                                	&nbsp;
                            	</td>
                            	<td style="text-align: right;font-size: 13px!important;font-weight: bold!important;">
                                	<h:outputLabel  value="#{cc.attrs.bill.netTotal-(cc.attrs.bill.paidAmount+cc.attrs.bill.patientEncounter.paidByCreditCompany)}"  >
                                    	<f:convertNumber pattern="#,##0.00" />
                                	</h:outputLabel>
                            	</td>
                        	</tr>

                        	<tr>
                            	<td>&nbsp;</td>
                            	<td>&nbsp;</td>
                            	<td style="text-align: right;"><h:outputLabel value="==========="/></td>
                        	</tr>
                    	</h:panelGroup>



                	</table>



                	<p:spacer height="50px"></p:spacer>
                	<h:outputLabel value="Prepared By : #{cc.attrs.bill.creater.code}" style="margin-left: 30%; text-decoration: overline;">
                	</h:outputLabel>
                	<h:outputLabel value="Cashier :" style="margin-left: 25%; text-decoration: overline;">
                	</h:outputLabel>
                	<h:outputLabel value="Patient/Guardian" style="margin-left: 10%; text-decoration: overline;">
                	</h:outputLabel>


            	</div>
            	<!--            	<div style="position: absolute;
                                 	left: 0%;
                                 	bottom:  3%;                                                         	 
                                 	font-size:10px!important;" rendered="#{sessionController.userPreference.applicationInstitution eq 'Ruhuna'}" >
                                	<h:outputLabel value="#{cc.attrs.bill.netTotal-cc.attrs.bill.paidAmount+cc.attrs.bill.patientEncounter.creditPaidAmount}" >
                                    	<f:convertNumber pattern="******0.00" />
                                	</h:outputLabel>
                            	</div>
                            	<div style="position: absolute;
                                 	left: 50%;
                                 	bottom:  3%;
                                 	font-size:10px!important;" rendered="#{sessionController.userPreference.applicationInstitution eq 'Ruhuna'}" >
                                	<h:outputLabel  value="#{cc.attrs.bill.paidAmount+cc.attrs.bill.patientEncounter.creditPaidAmount}" rendered="#{cc.attrs.bill.paidAmount !=0}" >
                                    	<f:convertNumber pattern="******0.00" />
                                	</h:outputLabel>
                            	</div>-->


        	</p:panel>
    	</div>
	</cc:implementation>
</html>
